package com.xiong.wuliao.HomeGame;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xiong.wuliao.R;

public class PlayerAdapter extends BaseAdapter {

	private Context context;
	private List<PlayerBean> list;

	public PlayerAdapter(Context context, List<PlayerBean> list) {
		this.context = context;
		this.list = list;
	}

	public int getCount() {
		return list.size();
	}

	public Object getItem(int position) {
		return list.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.player_item, null);
		}
		TextView name_tv = (TextView) convertView
				.findViewById(R.id.name_tv_item);
		TextView score_tv = (TextView) convertView
				.findViewById(R.id.score_tv_item);
		TextView rank_tv = (TextView) convertView
				.findViewById(R.id.rank_tv_item);

		name_tv.setText(list.get(position).getName() + "");
		rank_tv.setText(list.get(position).getId() + "");
		score_tv.setText(list.get(position).getScore() + "");

		return convertView;
	}

}
